package com.bls.cate.xiaomi;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.bls.blslib.base.BaseActivity;
import com.bls.blslib.eventbus.Event;
import com.bls.cate.R;
import com.bls.cate.constant.Interface;
import com.bls.cate.utils.AccountUtil;
import com.lzy.okgo.cache.CacheMode;
import com.lzy.okgo.model.HttpParams;

import com.xiaomi.mipush.sdk.MiPushClient;

/**
 * 　　  () 　　　  ()
 * 　　  ( ) 　　　( )
 * 　　  ( ) 　　　( )
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　┻　　　┃
 * 　　┗━┓　　　┏━┛
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣┓
 * 　　　　┃　　　　　　　┏┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 * ——————————————————
 * Created by BinglingSu on 2018/1/24.
 */

public class XMPushClientActivity extends BaseActivity {

    private EditText et2;
    private EditText et1;

    @Override
    protected boolean isRegisterEventBus() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_xm_push_client;
    }

    @Override
    protected void initFvb() {



        Button btn1 = findViewById(R.id.btn_1);
        Button btn2 = findViewById(R.id.btn_2);
        Button btn3 = findViewById(R.id.btn_3);
        et1 = findViewById(R.id.et_1);
        et2 = findViewById(R.id.et_2);


        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MiPushClient.setUserAccount(getApplicationContext(), et1.getText().toString().trim(), null);
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MiPushClient.unsetUserAccount(getApplicationContext(), et1.getText().toString().trim(), null);
            }
        });
        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                presenter.requestStrData(0, Interface.INTERFACE_XMSERVICE, CacheMode.NO_CACHE,
                        new HttpParams("RequestMethod", "XMPushToAccount"),
                        new HttpParams("PushId", AccountUtil.getUniqueId()),
                        new HttpParams("NickName", "BinglingSu"),
                        new HttpParams("Content", "这是测试"),
                        new HttpParams("NotifyId", "1"),
                        new HttpParams("OtherPushId", AccountUtil.getUniqueId())
                );
            }
        });
    }

    @Override
    protected void receiveStickyEvent(Event event) {
        super.receiveStickyEvent(event);
        if (event.getCode() == 0) {
            String aa = (String) event.getData();
            et1.setText(aa);
        }
    }


}
